import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userInfo: '',
    isLogin: false,
    test: ''
  },
  mutations: {
    setUserInfo (state, value) {
      state.userInfo = value
    },
    setLoginStatus (state, value) {
      state.isLogin = value
    },
    // setTest (state, value) {
    //   state.test = value
    // }
  },
  actions: {
    // 异步修改的数据可以放在这里，VUE推荐，更规范。本质还是通过mutations来修改state中的值~~用得少，练习
    // setTestA (store, value) {
    //   setTimeout(() => {
    //     store.commit('setTest', value)
    //   }, 1000)
    //   window.console.log(store)
    // }
  },
  modules: {}
})
